<?php
/*
	Cogumelo v0.1 - Innoto
	Copyright (C) 2009 Innoto Gestión para el Desarrollo Social S.L. <mapinfo@innoto.es>
	
	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.
	
	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
	USA.
*/

require_once('Classes/Utils/Template.inc');
require_once("Classes/Controllers/Session/UserAdminSessionController.inc");

/*
 * Esta funcion devuelve el numero de dias que hay entre la fecha inicial  y una final que se le pasan por argumentos
 */
 function restaFechas($dFecIni, $dFecFin)
  {
	$dFecIni = str_replace("-","",$dFecIni);
	$dFecFin = str_replace("-","",$dFecFin);
	ereg( "([0-9]{4})([0-9]{1,2})([0-9]{1,2})", $dFecIni, $aFecIni);
	ereg( "([0-9]{4})([0-9]{1,2})([0-9]{1,2})", $dFecFin, $aFecFin);
	$date1 = mktime(0,0,0,$aFecIni[2], $aFecIni[3], $aFecIni[1]);
	$date2 = mktime(0,0,0,$aFecFin[2], $aFecFin[3], $aFecFin[1]);
	return round(($date2 - $date1) / (60 * 60 * 24));
  }

$template = new Template();
$tplFile = "Admin/Main.tpl";
$accesssessioncontrol = new UserAdminSessionController();
$dateVo = $accesssessioncontrol->getUser();
$resultadofecha = restaFechas($dateVo->getTimelastchangepasswd() , $dateVo->getTimeLastLogin());
$change = false;

if($resultadofecha>=90)
	{
	$change = true;
	$template->assign('section', "changepasswd");
	}
	
$template->assign('change', $change);

// Print page
$template->display($tplFile, true, true);

?>